#include<stdio.h>
#include<pthread.h>
#include<unistd.h>

void* Routine(void*arg){
    //线程执行的函数，必须是void*和void*的参数对应pthread_creat,在上面可以转换
    char* msg = (char*)arg;
    while(1){
        printf("i am %s\n",msg);
        sleep(1);
    }

}
int main(){
    //创建线程
    pthread_t tid;
    pthread_create(&tid,NULL,Routine,(void*)"thread 1");
    //主线程死循环打印
    while(1){
        printf("i am main thread\n");
        sleep(2);
    }
    return 0;
}